package com.lecture.springlecture.controller;

import com.lecture.springlecture.entity.Student;
import com.lecture.springlecture.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2020/9/16 9:40
 */
@RestController
@RequestMapping("student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("updateStudent")
    public String updateStudent() {
        try {
            Student student = new Student();
            student.setStuNo(21);
            student.setStuName("测试修改13");
            int i = studentService.updateStudent(student);
            return i + "";
        } catch (Exception e) {
            return "修改失败：" + e.getMessage();
        }
    }

    @GetMapping("getStudent")
    public String getStudent() {
        Student student = studentService.getById(21);
        System.out.println(student.getStuName());
        return student.getStuName();
    }
}
